import 'package:flutter/material.dart';
import 'package:flutter_enjoy_plus_01/pages/login/index.dart';
import 'package:flutter_enjoy_plus_01/pages/profile/index.dart';
import 'package:flutter_enjoy_plus_01/utils/TokenManager.dart';
import 'pages/notice/index.dart';
import 'pages/tabs_page.dart';



void main() {
  runApp(  MaterialApp (
    routes: {
      "/": (context) => const TabsPage(),
      "/notice_detail": (context) => const NoticeDetail(),
      "/login": (context) => const LoginPage(),
      // "/profile": (context) => const ProfilePage(),
    },
     initialRoute: "/", 
     onGenerateRoute: (settings) {
       final token = tokenManager.getToken();
       if(token.isEmpty){
         return MaterialPageRoute(builder: (context) => const LoginPage());
       } else {
        if(settings.name == '/profile'){
          return MaterialPageRoute(builder: (context) => const ProfilePage());
        }
       }
       return null;
     },// 默认路由 第一个页面访问哪一个 ability中 loadContent()
  ));
}



